/**
 * 
 */
package com.module.bp.condition;

import com.module.bp.bus.BPHexMap;
import com.module.bp.player.BPParty;

/**
 * @author Donald
 */
public class LocationCondition implements Condition {
	/**
	 * the list of locations where the party must be when the parent event is
	 * fired for it to happen.
	 */
	private int[]	locations	= new int[0];
	/**
	 * Adds a location to the list of possible places where the event will
	 * happen.
	 * @param vertex the location
	 */
	public void addLocation(final int vertex) {
		int[] dest = new int[locations.length + 1];
		System.arraycopy(locations, 0, dest, 0, locations.length);
		dest[locations.length] = vertex;
		locations = dest;
		dest = null;
	}
	/**
	 * {@inheritDoc}
	 */
	@Override
	public boolean passes() {
		boolean passes = false;
		int current = BPHexMap.getInstance().getHexVertex(
				BPParty.getInstance().getCurrentHex());
		for (int i = 0; i < locations.length; i++) {
			if (locations[i] == current) {
				System.out.println("passes at location"+current);
				passes = true;
				break;
			}
		}
		return passes;
	}
}
